import csv
import random
import string
from faker import Faker


# 生成随机字符串
def random_string(length):
    letters = string.ascii_letters
    return ''.join(random.choice(letters) for i in range(length))


# 生成数据
data = []
for i in range(50):
    username = random_string(8)
    password = random_string(8)
    data.append([username + ':' + password + ':' + '200'])

# 写入CSV文件
with open('data.csv', 'w', newline='') as file:
    writer = csv.writer(file)
    writer.writerows(data)

print('数据已保存到data.csv文件中')
